import type { BasicTableColumn } from '@/components/table';
import TableFieldType from '@/components/table/src/types/field-type';
import type { FormSchema } from '@/components/form';
import FormFieldType from '@/components/form/src/types/field-type';

export const columns: BasicTableColumn[] = [
  {
    title: 'noticeId',
    key: 'noticeId',
    display: false,
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '公告标题',
    key: 'noticeTitle',
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '公告类型',
    key: 'noticeType',
    fieldType: TableFieldType.TAG,
    tagOptions: {
      options: [
        {
          label: '通知公告',
          value: '1',
          type: 'info',
        },
        {
          label: '系统公告',
          value: '2',
          type: 'warning',
        },
      ],
    },
  },
  {
    title: '公告状态',
    key: 'status',
    fieldType: TableFieldType.TAG,
    width: 100,
    align: 'center',
    tagOptions: {
      options: [
        {
          label: '正常',
          value: '0',
          type: 'success',
        },
        {
          label: '关闭',
          value: '1',
          type: 'error',
        },
      ],
    },
  },
  {
    title: '备注',
    key: 'remark',
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '创建时间',
    key: 'createTime',
    fieldType: TableFieldType.TEXT,
  },
];

export const schemas: FormSchema[] = [
  {
    field: 'noticeId',
    component: FormFieldType.INPUT,
    label: 'noticeId',
    display: false,
  },
  {
    field: 'noticeTitle',
    component: FormFieldType.INPUT,
    label: '公告标题',
    rules: [{ required: true }],
  },
  {
    field: 'noticeType',
    component: FormFieldType.RADIO_GROUP,
    label: '公告类型',
    componentProps: {
      options: [
        {
          label: '通知公告',
          value: '1',
        },
        {
          label: '系统公告',
          value: '2',
        },
      ],
    },
    defaultValue: '1',
  },
  {
    field: 'noticeContent',
    component: FormFieldType.RICH_TEXT_EDITOR,
    label: '公告内容',
    giProps: {
      span: 2,
    },
  },
  {
    field: 'status',
    component: FormFieldType.RADIO_GROUP,
    label: '公告状态',
    componentProps: {
      options: [
        {
          label: '正常',
          value: '0',
        },
        {
          label: '关闭',
          value: '1',
        },
      ],
    },
    defaultValue: '0',
  },
  {
    field: 'remark',
    component: FormFieldType.INPUT,
    label: '备注',
    componentProps: {
      type: 'textarea',
    },
    giProps: {
      span: 2,
    },
  },
];

export const searchSchemas: FormSchema[] = [
  {
    field: 'noticeTitle',
    component: FormFieldType.INPUT,
    label: '公告标题',
  },
  {
    field: 'noticeType',
    component: FormFieldType.SELECT,
    label: '公告类型',
    componentProps: {
      options: [
        {
          label: '通知公告',
          value: '1',
        },
        {
          label: '系统公告',
          value: '2',
        },
      ],
      valueField: 'value',
    },
  },
];
